package com.hewep.web.controller;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Record;
/**
 * 控制器基类
 * @author Administrator
 *
 */
public class BaseController extends Controller{
	
	protected Logger logger = LoggerFactory.getLogger(this.getClass());
	
	/******************  获取请求参数 *****************************/
	public Map<String, String> getParamMap(){
		Map<String, String> record = new HashMap<String, String>();
		Map<String, String[]> map= this.getParaMap();
		Set<String> keys = map.keySet();
		for (String string : keys) {
			//if(map.get(string)[0] != null && !"".equals(map.get(string)[0])){
//				record.put(string, map.get(string)[0]);
			//}
			if(map.get(string)[0] == null){
				record.put(string, "");
			}else{
				record.put(string, map.get(string)[0]);
			}
		}
		return record;
	}
	
	public Record getParamMap(String... paramNames){
		Record record = new Record();
		for (String paramName : paramNames) {
			record.set(paramName, this.getPara(paramName));
		}
		return record;
	}
	
}
